package io.renren.membermanage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.membermanage.entity.GenerateLog;
import io.renren.membermanage.mappper.GenerateLogMapper;
import io.renren.membermanage.service.GenerateLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Slf4j
@Service
public class GenerateLogServiceImpl extends ServiceImpl<GenerateLogMapper, GenerateLog> implements GenerateLogService {

    @Override
    public void cleanLogs() {
        LocalDateTime thirtyDaysAgo = LocalDateTime.now().minusDays(30);
        LambdaQueryWrapper<GenerateLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.lt(GenerateLog::getCreateTime, thirtyDaysAgo);
        this.remove(wrapper);
    }
}
